* Analytical process for Public Service Announcements and Promoting Face Masks During the Covid-19 Pandemic (Greene et al., PS)

cd "/Users/TJRyan/Dropbox/Corona/data/6_replication_files"

* Factor analysis and cronbach's alpha mentioned in text
use "wral.dta", clear
keep if pid3c == 2

factor mask mask_prevent_self mask_spread
alpha mask mask_prevent_self mask_spread, detail

* Correlation between attitude scale and behavioral measure
use "wral.dta", clear
keep if pid3c == 2
corr mask_sum mask_behavior // .63

* Study 1 PSA penetration
use "wral.dta", clear
keep if pid3c == 2

tab shelton_t // Examine 100 - cumulative percentage associated with 0.2
tab generic_t
tab shelton_decoy_t
tab generic_decoy_t

* Study 2 Percentage who participated in a prior wave
use "psa_experiment.dta", clear
tab priorwave w3flag, col 

* Study 2 Alpha for mask scale
use "psa_experiment.dta", clear
alpha mask_import mask_contract mask_spread

* Table 1
use "wral.dta", clear
keep if pid3c == 2

reg mask_sum shelton_t generic_t shelton_decoy_t generic_decoy_t, robust
reg mask_sum shelton_t generic_t shelton_decoy_t generic_decoy_t age_reg i.race i.edu i.female income agemean, robust
reg mask_behavior shelton_t generic_t shelton_decoy_t generic_decoy_t, robust
reg mask_behavior shelton_t generic_t shelton_decoy_t generic_decoy_t age_reg i.race i.edu i.female income agemean, robust

* Wald tests in Study 1
use "wral.dta", clear
keep if pid3c == 2

reg mask_sum *_t, robust
test shelton_t = generic_t // .88
reg mask_sum *_t age_reg i.race i.edu i.female income agemean, robust
test shelton_t = generic_t // .75
reg mask_behavior *_t, robust
test shelton_t = generic_t // .63
reg mask_behavior *_t age_reg i.race i.edu i.female income agemean, robust
test shelton_t = generic_t // .93

* Table 2
use "psa_experiment.dta", clear
reg mask_import i.psa3c, robust
reg mask_contract i.psa3c, robust 
reg mask_spread i.psa3c, robust
reg mask_sum i.psa3c, robust

* Wald tests for Table 2
use "psa_experiment.dta", clear
reg mask_import i.psa3c, robust
test 1.psa3c==2.psa3c // .53
reg mask_contract i.psa3c, robust 
test 1.psa3c==2.psa3c // .01
reg mask_spread i.psa3c, robust
test 1.psa3c==2.psa3c // .04
reg mask_sum i.psa3c, robust
test 1.psa3c==2.psa3c // .04

* Figure 1
use "psa_experiment.dta", clear

reg mask_sum shelton##i.pid3c_w3 generic##i.pid3c_w3 // 
margins, dydx(shelton generic) at(pid3c_w3=(0 1 2))
mplotoffset, offset(.2) level(95) horizontal ytitle("") xtitle("") graphregion(color(white)) ///
	xline(0, lpattern(dash)) recast(scatter) title("Partisanship" " ") ///
	plot1opts(lcolor(green) mcolor(green) msize(large)) ci1opts(lcolor(green)) ///
	plot2opts(lcolor(edkblue) mcolor(edkblue) msize(medlarge)) ci2opts(lcolor(edkblue)) ///
	xlab(0(.1).3) ylabel(, angle(90) nogrid) ysc(r(-.5 2.5)) //fxsize(10)
gr_edit	.legend.plotregion1.label[1].text = {}
gr_edit .legend.plotregion1.label[1].text.Arrpush Shelton PSA
gr_edit .legend.plotregion1.label[2].text = {}
gr_edit .legend.plotregion1.label[2].text.Arrpush Generic PSA
graph save "mask_partisan.gph", replace

reg mask_sum shelton##i.scicom generic##i.scicom  // 
margins, dydx(shelton generic) at(scicom=(0 1 2)) // Includes marginal effects among people low in confidence in scientific community, mentioned in text
mplotoffset, offset(.2) level(95) horizontal ytitle("") xtitle("") graphregion(color(white)) ///
	xline(0, lpattern(dash)) recast(scatter) title("Confidence in" "Scientific Community") ///
	plot1opts(lcolor(green) mcolor(green) msize(large)) ci1opts(lcolor(green)) ///
	plot2opts(lcolor(edkblue) mcolor(edkblue) msize(medlarge)) ci2opts(lcolor(edkblue)) ///
	xlab(-.1(.1).2) ylabel(, angle(90) nogrid) ysc(r(-.5 2.5)) // fxsize(30)
graph save "mask_science.gph", replace
	
reg mask_sum shelton##i.milcom generic##i.milcom  // 
margins, dydx(shelton generic) at(milcom=(0 1 2))
mplotoffset, offset(.2) level(95) horizontal ytitle("") xtitle("") graphregion(color(white)) ///
	xline(0, lpattern(dash)) recast(scatter) title("Confidence in" "Military") ///
	plot1opts(lcolor(green) mcolor(green) msize(large)) ci1opts(lcolor(green)) ///
	plot2opts(lcolor(edkblue) mcolor(edkblue) msize(medlarge)) ci2opts(lcolor(edkblue)) ///
	xlab(-.1(.1).2) ylabel(, angle(90) nogrid) ysc(r(-.5 2.5)) //fxsize(20)
graph save "mask_military.gph", replace
	
reg mask_sum shelton##i.covid_threat3 generic##i.covid_threat3  // 
margins, dydx(shelton generic) at(covid_threat3=(0 1 2))
mplotoffset, offset(.2) level(95) horizontal ytitle("") xtitle("") graphregion(color(white)) ///
	xline(0, lpattern(dash)) recast(scatter) title("Concern about" "Virus") ///
	plot1opts(lcolor(green) mcolor(green) msize(large)) ci1opts(lcolor(green)) ///
	plot2opts(lcolor(edkblue) mcolor(edkblue) msize(medlarge)) ci2opts(lcolor(edkblue)) ///
	xlab(-.1(.1).2) ylabel(, angle(90) nogrid) ysc(r(-.5 2.5)) //fxsize(20)
graph save "mask_covid.gph", replace

grc1leg "mask_partisan.gph" "mask_covid.gph" "mask_science.gph" "mask_military.gph" , ///
	rows(1) graphregion(color(white)) xsize(7.5) ysize(2.5) title("")
graph save "figure1.gph", replace
graph export "figure1.png", width(8000) replace
	

* Table SI-1 (Study 1)
use "wral.dta", clear
tab female
tab race
tab edu
tab agebin, m

tab female if pid3c == 2
tab race if pid3c == 2
tab edu if pid3c == 2
tab agebin if pid3c == 2, m
	
* Table SI-1 (Study 2)
use "psa_experiment.dta", clear

tab female if w3flag==1
tab race_w3 if w3flag==1
tab edu_w3 if w3flag==1
tab age_bin if w3flag==1, m

* Figure SI-1
use "wral.dta", clear

hist shelton_t, bin(6) graphregion(color(white)) frac xtitle("Exposure") ///
	ytitle("Proportion") title("Shelton Ad") ysc(r(0 1)) ylab(0(.2)1) ///
	xlab(0.083 "0" 0.25 "0.2" 0.416 "0.4" 0.583 "0.6" 0.75 "0.8" 0.9166 "1.0")
graph save "shelton_dist.gph", replace
	
hist generic_t, bin(6) graphregion(color(white)) frac xtitle("Exposure") ///
	ytitle("") title("Generic Ad") ysc(r(0 1)) ylab(0(.2)1) ///
	xlab(0.083 "0" 0.25 "0.2" 0.416 "0.4" 0.583 "0.6" 0.75 "0.8" 0.9166 "1.0")
graph save "generic_dist.gph", replace
	
hist shelton_decoy_t, bin(6) graphregion(color(white)) frac xtitle("Exposure") ///
	ytitle("Proportion") title("Decoy Shelton Ad") ysc(r(0 1)) ylab(0(.2)1) ///
	xlab(0.083 "0" 0.25 "0.2" 0.416 "0.4" 0.583 "0.6" 0.75 "0.8" 0.9166 "1.0")
graph save "shelton_d_dist.gph", replace
	
hist generic_decoy_t, bin(6) graphregion(color(white)) frac xtitle("Exposure") ///
	ytitle("") title("Decoy Generic Ad") ysc(r(0 1)) ylab(0(.2)1) ///
	xlab(0.083 "0" 0.25 "0.2" 0.416 "0.4" 0.583 "0.6" 0.75 "0.8" 0.9166 "1.0")
graph save "generic_d_dist.gph", replace
	
graph combine "shelton_dist.gph" "generic_dist.gph" "shelton_d_dist.gph" "generic_d_dist.gph", ///
	graphregion(color(white)) row(2) ycommon

graph save "fig_s1-1.gph", replace

* Table SI-2
use "wral.dta", clear
cor shelton_t generic_t shelton_decoy_t generic_decoy_t

* Table SI-3
use "wral.dta", clear
reg shelton_t wral fox cbs abc shelton_decoy_t generic_decoy_t, robust
reg generic_t wral fox cbs abc shelton_decoy_t generic_decoy_t, robust

* Table SI-4
* (Identical to Table 1 above)

* Table SI-5
use "wral.dta", clear
drop if pid3c != 2
reg mask *_t, robust
reg mask_prevent_self  *_t, robust
reg mask_spread *_t, robust

* Table SI-6
use "wral.dta", clear
keep if pid3c == 2

reg mask_sum *_s, robust
reg mask_sum *_s age_reg i.race i.edu i.female income agemean, robust
reg mask_behavior *_s, robust
reg mask_behavior *_s age_reg i.race i.edu i.female income agemean, robust

* Table SI-7
use "wral.dta", clear
drop if pid3c == 2

reg mask_sum *_t, robust
reg mask_sum *_t age_reg i.race i.edu i.female income agemean, robust
reg mask_behavior *_t, robust
reg mask_behavior *_t age_reg i.race i.edu i.female income agemean, robust
